<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../../css/reset.css" />
		<link rel="stylesheet" href="../../../css/cmms.css" />
		<link rel="stylesheet" href="../../../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../../css/iconfont.css" />
		<script src="../../../js/vconsole.min.js"></script>
	</head>
	<style type="text/css">
		#associate {
			position: relative;
			height: 100%;
		}
		.codeEntry{
			width: 100%;
			position: absolute;
			top: 45px;
		}
		#associate .mui-bar{
			background-color: #00507E;
		}
		#associate .mui-bar>a{
			color: #fff;
		}
		#associate .mui-bar>h1{
			color: #fff;
		}
		#selectSamplingBox>div{
			/* background-color: #2AC845; */
		}
		/* 样本信息 */
		#selectSamplingBox{
			width:100%;
			/* height: 100%; */
			overflow: scroll;
			padding: 10px;
		}
		#selectSamplingBox>div{
			width: 100%;
			/* border: none; */
			border: 1px solid #ccc;
			margin-bottom: 10px;
		}
		#selectSamplingBox>div>ul>li{
			width:100%;
			padding: 22px 20px;
		}
		#selectSamplingBox>div>ul>li:first-child{
			border-bottom: 1px solid #E6E6E6;
			padding: 11px;
		}
		#selectSamplingBox>div>ul>li:first-child>div:first-child{
			background-color: #f2f2f2;
			border-radius:20px; 
			height: 36px;
			display: flex;
		}
		#selectSamplingBox>div>ul>li:first-child input{
			width:70%;
			background-color: #f2f2f2;
			height: 26px;
			line-height: 26px;
			margin: 5px;
			border: none;
			font-size: 12px;
			text-align: left;
			padding: 0;
			color: #333;
		}
		#selectSamplingBox>div>ul>li>input::placeholder{
			font-size: 12px;
			text-align: center;
			color: #DBDBDB;
		}
		#selectSamplingBox>div>ul>li i{
			display: inline-block;
			/* padding-top: 3px; */
			padding: 7px 10px;
			font-size: 18px;
			color: #035380;
		}
		.samplingAmount{
			display: flex;
			justify-content: space-between;
			border-bottom: 1px solid #E6E6E6;
			padding: 5px 20px;
			line-height: 45px;
		}
		.samplingAmount>p{
			margin: 0;
			display: flex;
			justify-content: flex-start;
			flex-flow: row wrap;
			/* height: 30px; */
			line-height: 30px;
		}
		.samplingAmount>p>span{
			font-size: 12px;
			margin-left: 5px;
			word-wrap:break-word;
			word-break:break-all;
		}
		.samplingAmount>p>span.sampImg{
			width: 60px;
		}
		.samplingAmount>p>span>img{
			width: auto;
			height: auto;
			max-width: 100%;
			max-height: 100%;
		}
		#selectSamplingBox .samplingAmount>div{
			line-height: 30px;
		}
		#selectSamplingBox .samplingAmount>div>.numbox{
			margin: 6px 0px 6px 10px;
			display: flex;
			justify-content: space-between;
			flex-flow: row nowrap;
			align-items: center;
		}
		#selectSamplingBox .samplingAmount>div>.numbox>input{
			border:none;
			height: 21px;
			width: 21px;
			font-size: 12px;
			margin: 0;
			text-align: center;
		}
		#selectSamplingBox .samplingAmount>div>.numbox>span{
			vertical-align: middle;
		}
		#selectSamplingBox .samplingAmount>div>span>img{
			width: 21px;
			height: 21px;
			vertical-align: middle;
		}
		#selectSamplingBox .samplingAmount>div>span{
			font-size: 12px;
			color: #333;
			vertical-align: middle;
		}
		#selectSamplingBox>div.buttonBox{
			width: 100%;
			margin-top: 25px;
			text-align: center;
		}
		#selectSamplingBox>div.buttonBox>button{
			padding:0; 
		}
		#selectSamplingBox .sampName{
			margin: 0 15px;
		}
		#selectSamplingBox .sampName>p{
			font-size: 12px;
			color: #999;
			padding: 12px;
			border-bottom: 1px solid #E6E6E6;
			margin: 0;
		}
		#selectSamplingBox .sampName>p:last-child{
			border: none;
		}
		#selectSamplingBox>div>ul>li:nth-child(2){
			padding: 0;	
		}
		#samping{
			position: relative;
			overflow: hidden;
			padding: 11px 15px;
			background-color: #fff;
		}
		#samping>div{
			display: flex;
			justify-content: space-between;
		}
		#samping>div>div{
			height: 26px;
			line-height: 26px;
		}
		#samping>div>div>span{
			color:#B4C1CC;
		}
		#samping>div>div>i{
			width: 30px;
			text-align: center;
			font-size: 18px;
			color: #2470AA;
		}
		#patienBox{
			width: 100%;
			position: absolute;
			top: 45px;
		}
		#patienBox>ul>li{
			width: 100%;
			display: flex;
			justify-content: space-between;
		}
		#patienBox>ul>li input{
			margin: 0;
			height: 30px;
			font-size: 15px;
			color: #808080;
			border: none;
			text-align: right;
		}
		#patienBox>ul>li input::placeholder{
			color: #ccc;
		}
		#patienBox>ul>li input:disabled{
			background-color:#F5F5F5;
			color:#ACA899;
		}
		#patienBox>ul>li.phoneBox{
			background-color: #F5F5F5;
		}
		/* background-color: #F5F5F5; */
		#patienBox>ul>li>div{
			display: flex;
			justify-content: flex-end;
			flex-flow: nowrap row;
			width: 70%;
			line-height: 30px;
		}
		#patienBox>ul>li>div>.samplingTime{
			color: #ccc;	
			padding-right: 15px;
			font-size: 15px;
		}
		#patienBox>ul>li>div>i{
			width: 30px;
			text-align: center;
			line-height: 30px;
		}
		#patienBox>ul>li .noIcon{
			padding-right: 23px;
		}
		#patienBox>ul>li>label{
			color: #333;
			font-size: 15px;
			line-height: 30px;
		}
		#patienBox>ul>li>.selectBox>input:nth-child(2){
			width: 60px;
		}
		#patienBox>ul>li.singleListItem8{
			flex-flow: wrap;
		}
		#patienBox>ul>li.singleListItem8>label{
			width: 100%;
		}
		#patienBox>ul>li.singleListItem8>div{
			width: 100%;
		}
		#patienBox>ul>li.singleListItem8>div>textarea{
			margin: 0;
			height: 90px;
			padding: 0;
			border:none;
			font-size: 14px;
		}
		/*上传图片*/
		#applyBox{
			width: 100%;
			position: absolute;
			top: 45px;
			padding: 10px;
		}
		/* #applyBox .applyImgBox{
			padding-top:10px;
			padding-bottom: 22px;
		} */
		#applyBox .applyImgBox ul{
			margin-top: 10px;
			display: flex;
			flex-flow:row wrap;
		}
		#applyBox .applyImgBox ul li{
			width: 54px;
			height: 54px;
			background-color: #f2f2f2;
			border-radius: 5px;
			text-align: center;
			line-height: 54px;
			margin: 5px;
		}
		#applyBox .applyImgBox ul li img{
			width: 52px;
			height: 52px;
		}
		#applyBox .applyImgBox ul li i{
			color:#ccc;
			font-size: 23px;
		}
		#applyBox .applyImgBox ul li.localImg{
			position: relative;
		}
		#applyBox .applyImgBox>ul>li.localImg>img{
			position: absolute;
			top: 0;
			left: 0;
		}
		#applyBox .applyImgBox>ul>li.localImg>i.icon-shanchu {
			display: block;
			font-size: 14px;
			position: absolute;
			top: -7px;
			right: -7px;
			color: #ff0000;
			height: 14px;
			width: 14px;
			line-height: 14px;
			z-index: 5;
		}
		
		.btnBox{
			text-align: center;
			/* margin-top: 20px; */
			margin: 20px 0;
		}
		.btnBox>.submit-btn{
			width: 340px;
			padding: 0;
			margin: 0 auto;
			border: 0;
			font-size: 16px;
			background-color: #42A3FF;
		}
		.icon-date{
			color: #42A3FF;
		}
		textarea::-webkit-input-placeholder{
			font-size: 14px;
			color: #ccc;
		}
	 .redTip{
			position: relative;
			padding-left:10px; 
		}
		.redTip::before{
			content: '*';
			display: block;
			color: red;
			width: 10px;
			position: absolute;
			left: 0;
			top: 0px;
		}
		#orderDetail{
			position: absolute;
			top: 45px;
			width: 100%;
		}
		#single1>ul>li>div:first-child{
			line-height: 40px;
			background-color: #F2F4FB;
		}
		#single1>ul>li>div:nth-child(2){
			padding: 10px 15px;
		}
		#single1>ul>li>div.samplingBox{
			padding: 10px 15px 0;
		}
		#single1>ul>li>div.samplingTime{
			padding: 0 15px 10px;
		}
		#single1>ul>li>div{
			padding: 0 15px;
		}
		#single1>ul>li>div>p{
			line-height: 30px;
		}
		#single1 .proInfo>p{
			display: flex;
			justify-content: space-between;
		}
		#single1 .mui-table-view-cell{
			padding: 0;
		}
		#single1>ul>li.reportBox>div>div>p{
			color: #A8ACB3;
			font-size: 14px;
			line-height: 40px;
		}
		#single1>ul>li.reportBox>div>div>p.selBlue{
			color: #3985BE;
		}
		#single1>ul>li.reportBox>div>div>div.noticeInfo{
			padding-left: 15px;
		}
		#single1>ul>li.reportBox>div>div>div.noticeInfo>p>span{
			display: block;
			min-width: 40px;
			height: 16px;
			line-height: 16px;
			position: absolute;
			color: #fff;
			font-size: 12px;
			text-align: center;
			border-radius: 4px 0 0 4px;
			background-color: #C2DAFF;
			top: 0;
			right: 0;
			padding: 0 5px;
		}
		/* #single1>ul>li.reportBox>div>div>div.noticeInfo>p>span.normal{
			background-color: #C2DAFF;
		} */
		#single1>ul>li.reportBox>div>div>div.noticeInfo>p>span.prviate{
			background-color: #FFD9C2;
		}
		#single1>ul>li.reportBox>div>div>div.noticeInfo>p{
			line-height: 26px;
			font-size: 13px;
			position: relative;
		}
		/* noticeInfo */
		#single1>ul>li.reportBox>div>div>p>i{
			margin-right: 10px;
		}
		.mui-table-view-cell:after {
			position: absolute;
			right: 0;
			bottom: 0;
			left: 0px;
			height: 1px;
			content: '';
			-webkit-transform: scaleY(.5);
			transform: scaleY(.5);
			background-color: #c8c7cc;
		}
		#single1 .singleListItem5>div>img{
			width: 52px;
			height: 52px;
			margin: 0 5px 5px 0;
		}
		.mui-popup-button{
			display: block;
		}
		.mui-popup-buttons {
		    position: relative;
				display: block;
				height: auto;
		}
		.mui-popup-button:first-child {
		  border-radius: 0;
		}
	</style>
	<body>
		<div id="associate" v-cloak>
			<header class="mui-bar mui-bar-nav mui-bar-nav-bg">
			    <a id="icon-menu" class="mui-icon mui-icon-left-nav mui-pull-left" @tap="back"></a>
			    <a class="mui-icon mui-pull-right iconfont icon-gerenziliao" @tap="editPatientInfo" v-if="patientIcon"></a>
			    <h1 class="mui-title">{{topTitle}}</h1>
			</header>
			<div class="codeEntry" v-show="samplingShow" :style="contentStyleObj">
				<div id="samping">
					<div @tap="selectSamplingTime">
						<label class="redTip">采集时间</label>
						<div>
							<span class="samplingTime">{{samplingTime|replaceT}}</span>
							<i class="icon iconfont icon-date right"></i>
						</div>
					</div>
				</div>
				<div id="selectSamplingBox">
					<div class="panel" v-for="samplings,index in SamplingParams">
						<ul>
							<li>
								<div>
									<i class="icon iconfont icon-sousuo"></i>
									<input type="text" placeholder="请扫描或输入检验条码" v-model="samplings.specimenBarcodes" />
									<!-- @change="addBarCode(index,samplings.outLabId)" -->
									<i class="icon iconfont icon-saoma right" @tap="scanBarcode(index,samplings)"></i>
								</div>
							</li>
							<li>
								<div class="samplingAmount" v-for="(sampCo,scIndex) in samplings.samplingColorVos">
									<p class="left">
										<span class="sampImg" @tap="getSampImg(sampCo.sampImg,$event)"><img :src="sampCo.sampImg" alt=""></span>
										<span>{{sampCo.samplingColor}}</span> 
										<span>{{sampCo.specimenTypeName}}</span>
										<span>{{sampCo.count}}{{sampCo.unitName}}</span>
									</p>
									<div>
										<p class="numbox right">
											<span class="iconfont icon-jian" @tap="minusNum(index,scIndex)"></span>
											<input class="input" v-model="sampCo.samplingNum" readonly unselectable="on"/>
											<span class="iconfont icon-jia" @tap="plusNum(index,scIndex)"></span>
										</p>
									</div>
								</div>
								<div class="sampName" v-for="sampPv in samplings.samplingProjectVos">
									<p>{{sampPv.projectName}}</p>
								</div>
							</li>
						</ul>
					</div>
				</div>
				<div class="btnBox">
					<button class="submit-btn" @tap="saveSample">下一步</button>
				</div>
			</div>
			<div id="applyBox" v-show="applyShow">
				<div class="applyImgBox">
					<!-- <div>申请单上传</div> -->
					<ul>
						<li v-for="src,index in imgSrcs" class="localImg" v-if="imgSrcs&&imgSrcs.length>0">
							<i class="iconfont icon-shanchu" @tap="delwxIMG(index)"></i>
							<img :src="src" alt="申请单" @tap="getImg(src)"/>
						</li>
						<li @tap="uploadImg" v-if="imgSrcs.length<5"><i class="icon iconfont icon-jiahao" ></i></li>
					</ul>
				</div>
				<div class="btnBox">
					<button class="submit-btn" @tap="saveApply">下一步</button>
				</div>
			</div>
			<!-- 患者信息 -->
			<div id="patienBox" v-show="patientShow">
				<ul class="mui-table-view">
					<li class="mui-table-view-cell">
						<label>姓名</label>
						<div class="noIcon">
							<input type="text" v-model="patientName" placeholder="请输入姓名"/>
						</div>
					</li>
					<li class="mui-table-view-cell" @tap="selectSex">
						<label>性别</label>
						<div>
							<input type="text" readonly unselectable="on" v-model="sexMsg" placeholder="请选择性别"/>
							<i class="mui-icon mui-icon-arrowright"></i>
						</div>
					</li>
					<li class="mui-table-view-cell" >
						<label>年龄</label>
						<div class="selectBox">
							<input type="tel" v-model="dateBirth" placeholder="请输入年龄" />
							<input type="text"  @tap="selectAgeUnit" readonly unselectable="on" v-model="ageUnit" />
							<i class="iconfont icon-chakangengduo"></i>
						</div>
					</li>
					<li class="mui-table-view-cell phoneBox">
						<label>联系电话</label>
						<div class="noIcon">
							<input type="tel" v-model="patientPhone" disabled="disabled" :maxlength="11" placeholder="请输入联系电话"/>
						</div>
					</li>
					<li class="mui-table-view-cell singleListItem8" >
						<label>备注</label>
						<div class="remarkBox">
							<textarea class="content" placeholder="请输入内容" v-model="remark"></textarea>
						</div>
					</li>
				</ul>
				<div class="btnBox">
					<button class="submit-btn" id="savePatient" @tap="confirmPatientMsg">保存</button>
				</div>
			</div>
			<div id="orderDetail" v-show="orderDeSHow">
				<div id="single1">
					<ul class="mui-table-view">
						<li class="mui-table-view-cell">
							<div>
								<span class="title">受检人信息</span>
							</div>
							<div>
								<p>姓名：{{patientName}}</p>
								<p>性别：{{sexMsg}}</p>
								<p>年龄：{{evage}}</p>
								<p>联系电话：{{patientPhone}}</p>
								<!-- <p>采集时间：{{samplingTime}}</p> -->
								<p>备注：{{remark}}</p>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div>
								<span class="title">项目信息</span>
							</div>
							<div class="proInfo" v-if="proInfo&&proInfo.length>0">
								<p v-for="pInfo in proInfo">
									<span>{{pInfo.projectName}}</span>
									<span>￥{{pInfo.marketPrice}}</span>
								</p>
								<!-- <p class="total">
									<span>总计：</span>
									<span>￥{{selectItemsSum}}</span>
								</p> -->
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div>
								<span class="title">项目信息</span>
							</div>
							<div class="proInfo">
								<p>
									<span>检验金额:</span>
									<span>{{amount}}</span>
								</p>
								<p class="total">
									<span>应付金额:</span>
									<span>{{actualAmount}}</span>
								</p>
								<p class="total">
									<span>优惠金额:</span>
									<span>{{discountAmount}}</span>
								</p>
								<p class="total">
									<span>实付金额:</span>
									<span>{{settleAmount}}</span>
								</p>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div>
								<span class="title">试管信息</span>
							</div>
							<div class="samplingBox" v-for="specimenS in specimenSamplingBox">
								<p><span>条形码:{{specimenS.specimenBarcodes}}</span></p>
								<p v-for="specimen in specimenS.samplingColorVos">
									<span>{{specimen.samplingColor}}</span> 
									<span>×{{specimen.samplingNum}}</span>
								</p>
							</div>
							<div class="samplingTime">
								<p><span>采集时间:{{samplingTime}}</span></p>
							</div>
						</li>
						<li class="mui-table-view-cell">
							<div>
								<span class="title">送检诊所</span>
							</div>
							<div>
								<p><span>送检诊所:{{hospitalName}}</span></p>
								<p>
									<span>送检医生:{{doctorName}}</span>
								</p>
							</div>
						</li>
						<li class="uploadBox mui-table-view-cell singleListItem5">
							<div>申请单信息</div>
							<div class="localImg">
								<img v-for="src,index in imgSrcs" :src="src" alt="申请单" @tap="getImg(src)"/>
							</div>
						</li>
						<!-- <li class="reportBox mui-table-view-cell">
							<div>出报告通知</div>
							<div>
								<div>
									<p @tap="selectSale" :class="{'selBlue':saleShow}"><i class="iconfont icon-tubiaozhizuomoban left" 
											:class="{'icon-xuanzhong':saleShow}"></i>业务员</p>
									<div class="noticeInfo">
										<p v-for="saleNotice in saleNoticeList">{{saleNotice.notifyTypeName}}通知  时间段{{saleNotice.notifyStartTime}}-{{saleNotice.notifyEndTime}}<span :class="{'prviate':saleNotice.configTypeName=='自定义配置'}">{{saleNotice.configTypeName}}</span></p>
									</div>
								</div>
								<div>
									<p @tap="selectDoctor" :class="{'selBlue':doctorShow}"><i class="iconfont icon-tubiaozhizuomoban left" 
											:class="{'icon-xuanzhong':doctorShow}"></i>医生</p>
									<div class="noticeInfo">
										
										<p v-for="doctorNotice in doctorNoticeList">{{doctorNotice.notifyTypeName}}通知  时间段{{doctorNotice.notifyStartTime}}-{{doctorNotice.notifyEndTime}}<span :class="{'prviate':doctorNotice.configTypeName=='自定义配置'}">{{doctorNotice.configTypeName}}</span></p>
									</div>
								</div>
								<div>
									<p @tap="selectPatient" :class="{'selBlue':patient1Show}"><i class="iconfont icon-tubiaozhizuomoban left" 
											:class="{'icon-xuanzhong':patient1Show}"></i>患者</p>
									<div class="noticeInfo">
										<p v-for="patientNotice in patientNoticeList">{{patientNotice.notifyTypeName}}通知  时间段{{patientNotice.notifyStartTime}}-{{patientNotice.notifyEndTime}}<span :class="{'prviate':patientNotice.configTypeName=='自定义配置'}">{{patientNotice.configTypeName}}</span></p>
									</div>
								</div>
							</div>
						</li> -->
					</ul>
				</div>
				<div class="btnBox">
					<button class="submit-btn" @tap="submitInfo">提交</button>
				</div>
			</div>
		</div>
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/vue.js"></script>
		<script src="https://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
		<script src="../../../js/mui.picker.min.js"></script>
		<script src="../../../js/cmms.js?time=222"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<script type="text/javascript">
			new Vue({
				el:"#associate",
				data(){
					return{
						fromWeb:'',
						topTitle:'',
						boxName:'samplePage',
						samplingTime:'请选择采集时间',
						samplingShow:true,
						patientIcon:true,
						patientShow:false,
						applyShow:false,
						orderDeSHow:false,
						SamplingParams:[
						],
						patientName:'',
						sexMsg:'',
						dateBirth:'',
						ageUnit:'岁',
						patientPhone:'',
						remark:'',
						partnerHospitalName:'',
						partnerHospitalUserName:'',
						evage:'',
						pInfo:[],
						proInfo:[],
						selectItemsSum:'',
						specimenSamplingParams:[],//录单提交样本信息集合
						specimenSamplingBox:[],//显示主页的样本信息
						imgSrcs:[
							// "http://attach.bbs.miui.com/forum/201401/21/155727b9kqqkvssztk93f0.jpg","http://attach.bbs.miui.com/forum/201401/21/155727b9kqqkvssztk93f0.jpg"
						],//选择图片地址
						imgIds:[],//附件id集合
						orderId:'',
						contentStyleObj:{
							height:''
						},
						patientInfo:{
							"age": '',
							"ageUnit": '',
							"orderId": '',
							"patientName": '',
							"remark": '',
							"sex": ''
						},
						sexCode:'',
						orderProjectVos:[],
						amount:0,
						actualAmount:0,
						discountAmount:0,
						settleAmount:0,
						hospitalName:'',
						doctorName:'',
						specimenBarCodeParamList:[],
						userId:'',
						notifyUserTypes:[],
						saleNoticeList:[],
						doctorNoticeList:[],
						patientNoticeList:[],
						patient1Show:false,
						saleShow:false,
						doctorShow:false,
						partnerHospitalLabId:''
					}
				},
				created() {
					window.addEventListener('resize', this.getHeight);
					this.getHeight()
				},
				mounted(){
					var vConsole = new VConsole();
					this.getUrl();
					this.init();
					this.setTopTitle();
					this.getBaseInfo();
					this.getPages();
				},
				methods:{
					getHeight(){
						this.contentStyleObj.height=window.innerHeight-46+'px';
						console.log(this.contentStyleObj.height)
					},
					init(){
						/*接口配置*/
							AT.muiAjax('/partner-sale/partnerSale/wxConfig','post',{url:location.href.split('#')[0]},function(res){
							wx.config({
								//debug: true,
								appId:res.appId,
								timestamp:res.timestamp,
								nonceStr:res.nonceStr,
								signature:res.signature,
								jsApiList:['scanQRCode','chooseImage','uploadImage','previewImage']
							});
						});
						let orderProjectVos = localStorage.getItem('orderProjectVos');
						this.proInfo = JSON.parse(orderProjectVos);
						let amountStr = localStorage.getItem('amountInfo');
						let amountInfo = JSON.parse(amountStr);
						this.amount = amountInfo.amount;
						this.actualAmount = amountInfo.actualAmount;
						this.discountAmount = amountInfo.discountAmount;
						this.settleAmount = amountInfo.settleAmount;
						this.hospitalName = localStorage.getItem('hospitalName');
						this.doctorName = localStorage.getItem('doctorName');
						this.partnerHospitalLabId = localStorage.getItem('partnerHospitalLabId');
					},
					//扫描10-12位服务码
					scanBarcode(index,samplings){
						let _index = index;
						let _this=this;
						let _arr = _this.SamplingParams;
						wx.scanQRCode({
							needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
							scanType: ["barCode"], // 可以指定扫二维码还是一维码，默认二者都有
							success: function (res) {
								let resultStr = res.resultStr.split(',');
								let scanbarCode = resultStr[resultStr.length-1]; 
								mui.alert('扫到的条码为：'+scanbarCode);
								console.log(scanbarCode)
								let isUnique=false;
								for(let i=0;i<_arr.length;i++){
									console.log(_this.SamplingParams[i].specimenBarcodes);
									if(scanbarCode == _this.SamplingParams[i].specimenBarcodes){
										isUnique=true;
										break;
									}
								}
								if(isUnique){
									mui.alert('该条码已存在，请重新输入!');
								}else{
									let url = '/partner-sale/ludan/checkSpecimenBarcodeIsUnique';
									mui.ajax(AT.baseUrl + url, {
										data: {
											outLabId:samplings.outLabId,
											partnerHospitalLabId: _this.partnerHospitalLabId,
											specimenBarcode: scanbarCode
										},
										dataType: 'json', //服务器返回json格式数据
										type: 'post', //HTTP请求类型
										//timeout: 10000, //超时时间设置为10秒；
										crossDomain: true,
										headers:{'Content-Type':'application/json','token':localStorage.getItem(localStorage.getItem("state")+"_sale_token")},
										success: (res)=>{
											console.log(res)
											let realData = res.data;
											if(res.code === 0){
												_this.$forceUpdate();
												_this.$set(_arr[_index],'specimenBarcodes',scanbarCode);
											}else if(res.code === 1){
												_this.isBarcodeSure = false;
												_this.show1=false;
												_this.show5 = true;
												mui.toast(res.msg);
												_this.$forceUpdate();
												// _this.$set(_arr[_index],'specimenBarcodes','');
											}else{
												if(res.msg!='用户未登录'){
													mui.toast(res.msg);
												}
											}
										},
										error: (xhr, type, errorThrown) =>{
											console.log('err'+type);
										}
									});
								}
							}
						});
					},
					getPages(){
						let _this = this;
						AT.muiAjax('/partner-sale/ludan/specimenSamplingsByOrderId','post',{
							id:_this.orderId
						},function(res){
							console.log(res);
							let realData = res;
							let SamplingParamsArr = [];
							let productsList = [];
							for(let i=0;i<realData.length;i++){
								// _this.SamplingParams[i]["specimenBarcodes"]='';
								let samplingColorVos = realData[i].samplingColorVos;
								let sampCoArr = [];
								for(let j=0;j<samplingColorVos.length;j++){
									let scObj = {
										consumablesFileTypeId:samplingColorVos[j].consumablesFileTypeId,
										sampImg:'',
										count:samplingColorVos[j].count,
										samplingColor:samplingColorVos[j].samplingColor,
										samplingNum:samplingColorVos[j].samplingNum,
										specimenTypeName:samplingColorVos[j].specimenTypeName,
										unitName: samplingColorVos[j].unitName
									};
									if(samplingColorVos[j].consumablesFileTypeId){
										scObj.sampImg = _this.getImgSrc(samplingColorVos[j].consumablesFileTypeId);
									}
									console.log(scObj);
									sampCoArr.push(scObj);
								}
								console.log(sampCoArr)
								let sampParObj={
									outLabId: realData[i].outLabId,
									samplingColorVos:sampCoArr,
									samplingProjectVos:realData[i].samplingProjectVos,
									specimenBarcodes: "",
								};
								SamplingParamsArr.push(sampParObj);
							}
							console.log(SamplingParamsArr)
							_this.SamplingParams = SamplingParamsArr;
						});
					},
					getBaseInfo(){
						let patientInfo = localStorage.getItem('patientInfo');
						this.patientInfo = JSON.parse(patientInfo);
						this.patientName = this.patientInfo.patientName;
						this.sexMsg = this.patientInfo.sex==1?'女':'男';
						this.dateBirth = this.patientInfo.age;
						this.ageUnit = this.patientInfo.ageUnit;
						this.evage = this.dateBirth + this.ageUnit;
						this.patientPhone = this.patientInfo.patientMobile;
						this.remark = this.patientInfo.remark;
					},
					/*获取微信端URI后的code和state*/
					getUrl() {
						let _this = this;
						var url = location.search; //获取url中"?"符后的字串    
						var theRequest = new Object();
						console.log(url);
						if(url.indexOf("?") != -1) {
							var str = url.substr(1);
							console.log(str);
							strs = str.split("&");
							for(var i = 0; i < strs.length; i++) {
								theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
							}
						}
						console.log(theRequest);
						_this.code = theRequest.code;
						_this.state = theRequest.state;
						_this.fromWeb = theRequest.fromWeb;
						_this.orderId = theRequest.orderId;
					},
					setTopTitle(){
						if(this.webName = 'codeList'){
							this.topTitle = '条码录入';
						}
					},
					//返回
					back(){
						switch(this.boxName){
							case 'samplePage':
								location.href = 'noCodeList.html';
								break;
							case 'patientPage':
								this.patientShow = false;
								this.samplingShow = true;
								this.patientIcon = true;
								this.boxName = 'samplePage';
								this.topTitle = '条码录入';
								break;
							case 'applyPage':
								this.samplingShow = true;
								this.applyShow = false;
								this.patientIcon = true;
								this.boxName = 'samplePage';
								this.topTitle = '条码录入';
								break;
							case 'orderDetailPage':
								this.applyShow = true;
								this.orderDeSHow = false;
								this.boxName = 'applyPage';
								this.topTitle = '上传申请单';
								break;
						}
					},
					//编辑患者信息
					editPatientInfo(){
						this.patientShow = true;
						this.samplingShow = false;
						this.patientIcon = false;
						this.boxName = 'patientPage';
						this.topTitle = '编辑受检人信息';
					},
					//年月天
					selectAgeUnit(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([
							{value:'年',text:'岁'},
							{value:'个月',text:'个月'},
							{value:'天',text:'天'}
						]);
						picker.show(function (selectItems) {
						    _this.ageUnit=selectItems[0].text;
						})
					},
					//性别选择器
					selectSex(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([{value:'2',text:'男'},{value:'1',text:'女'}]);
						picker.show(function (selectItems) {
						    _this.sexMsg=selectItems[0].text;
							_this.sexCode = selectItems[0].value;
						    picker.dispose();
							picker = null;
						})
					},
					// 
					confirmSamp(){
						// this.patient = this.
						this.samplingShow = false;
						this.applyShow = true;
						this.patientIcon = false;
						this.boxName = 'applyPage';
						this.topTitle = '上传申请单';
					},
					//去订单详情预览页
					saveApply(){
						if(this.imgIds.length>0){
							this.applyShow = false;
							this.orderDeSHow = true;
							this.boxName = 'orderDetailPage';
							this.topTitle = '预览';
						}else{
							mui.toast('请先上传申请单！');
						}
					},
					//保存样本信息
					saveSample(){
						console.log(this.applyShow);
						console.log(this.samplingShow);
						console.log(this.isBarcodeSure)
						//specimenSamplingParams 录单提交集合
						let _this = this;
						if((_this.samplingTime=='')||(_this.samplingTime=='请选择采集时间')){
							mui.toast("采集时间不能为空，请选择！");
							return false;
						}
						let reg=/^[A-Za-z0-9]+$/;
						_this.isBarcodeSure = false;
						_this.selectItemsSum2 = _this.selectItemsSum;
						_this.specimenSamplingParams = [];
						let SamplingParams = _this.SamplingParams;
						let projectIds = [];
						let projectIdsArr = [];
						let projectColor = [];
						let samplingColor = '';
						let samplingNum = 0;
						let specimenTypeName = '';
						 
						let specimenBarCodeParamList =_this.specimenBarCodeParamList;
						let specimenBarCodeParamArr = [];
						let sObj = {};
						console.log(SamplingParams);
						for(let i=0;i<SamplingParams.length;i++){ 
							let barCode = SamplingParams[i].specimenBarcodes;
							let outLabId = SamplingParams[i].outLabId;
							if(barCode!==''){
								let specimenBarCodeObj = {
									outLabId:outLabId,
									partnerHospitalLabId: _this.partnerHospitalLabId,
									specimenBarcode: barCode
								}
								specimenBarCodeParamArr.push(specimenBarCodeObj);
								_this.specimenBarCodeParamList = specimenBarCodeParamArr;
								// console.log(SamplingParams[i].outLabId)
								projectIds = SamplingParams[i].samplingProjectVos;
								let projectId = [];
								for(let j=0;j<projectIds.length;j++){
									projectId[j]=projectIds[j].projectId;
								}
								projectColor = SamplingParams[i].samplingColorVos;
								let colorArr = [];
								let specimenArr = [];
								for(let k=0;k<projectColor.length;k++){
									colorArr[k] = projectColor[k].samplingColor;
									specimenArr[k] = projectColor[k].specimenTypeName;
									samplingNum += projectColor[k].samplingNum;
								}
								SamplingParams[i].samplingColorVos = projectColor;
								samplingColor = colorArr.join('、');
								specimenTypeName = specimenArr.join('、');
								// console.log(samplingColor,samplingNum)
								// console.log(projectId);
								let obj = {
									"outLabId": SamplingParams[i].outLabId,
									"projectIds":projectId,
									"samplingColor":samplingColor,
									"samplingNum":samplingNum,
									"specimenBarcode":SamplingParams[i].specimenBarcodes,
									"specimenTypeName":specimenTypeName
								}
								projectIdsArr.push(obj);
								_this.specimenSamplingParams = projectIdsArr;
								_this.specimenSamplingBox = _this.SamplingParams;
								console.log(_this.specimenSamplingParams)
								console.log(_this.specimenSamplingBox)
								_this.isBarcodeSure = true;
							}
							else{
								mui.toast("条码不能为空，请绑定条码！");
								_this.applyShow = false;
								_this.samplingShow = true;
								_this.isBarcodeSure = false;
								break;//跳出循环
							}
						}
						console.log(_this.isBarcodeSure);
						if(_this.isBarcodeSure){
							console.log('为true时');
							let len = _this.specimenBarCodeParamList.length;
							let flag = false;
							console.log(len);
							if(len>1){
								console.log('长度>1');
								for(let j=0;j<len-1;j++){
									console.log('进入循环');
									if(_this.specimenBarCodeParamList[j].specimenBarcode == _this.specimenBarCodeParamList[j+1].specimenBarcode) {
										mui.toast("所填条码重复请重填！");
										flag = false;
										break;
									}else{
										console.log('进入判断');
										flag = true;
									}
								}
							}else{
								console.log('长度为1');
								flag = true;
							}
							if(flag){
								_this.checkMultiBarcode(_this.specimenBarCodeParamList);
							}
						}else{
							// _this.isBarcodeSure = false;
							console.log(123)
						}
						console.log(_this.specimenBarCodeParamList);
						console.log(_this.SamplingParams)
						console.log(this.proInfo)
					},
					//确认受检人信息
					confirmPatientMsg(){
						let _this = this;
						console.log(_this.sexMsg)
						let regPhone= /^1[3456789]\d{9}$/;
						let regAge = /^[0-9]*$/; 
						if(this.patientName==''){
							mui.alert('患者姓名不能为空');
							return false;
						}
						if(this.sexMsg==''){
							mui.alert('性别不能为空');
							return false;
						}
						if(this.dateBirth==''){
							mui.alert('患者年龄不能为空');
							return false;
						}
						if(!(regAge.test(this.dateBirth))){
							mui.alert('年龄必须为数字');
							return false;
						} 
						_this.sexCode = (_this.sexMsg=="男")?2:1;
						mui("#savePatient").button('loading');
						let url = '/partner-sale/ludan/editPatientInfo';
						let patientInfo = {
							"age": _this.age ,
							"ageUnit": _this.ageUnit,
							"orderId": _this.orderId,
							"patientName": _this.patientName,
							"remark": _this.remark,
							"sex":_this.sexCode
						}
						mui.ajax(AT.baseUrl + url, {
							data: patientInfo,
							dataType: 'json', //服务器返回json格式数据
							type: 'post', //HTTP请求类型
							//timeout: 10000, //超时时间设置为10秒；
							crossDomain: true,
							headers:{'Content-Type':'application/json','token':localStorage.getItem(localStorage.getItem("state")+"_sale_token")},
							success: (res)=>{
								if(res.code === 0){
									mui.toast(res.data);
									_this.samplingShow = true;
									_this.patientShow = false;
									_this.patientIcon = true;
									_this.boxName = 'samplePage';
									_this.topTitle = '条码录入';
									let patientLocal = {
										"age": _this.age,
										"ageUnit": _this.ageUnit,
										"orderId": _this.orderId,
										"patientName": _this.patientName,
										"remark": _this.remark,
										"sex": _this.sexCode,
										"patientMobile":_this.patientPhone
									}
									localStorage.setItem('patientInfo',JSON.stringify(patientLocal));					
									_this.getBaseInfo();
									mui("#savePatient").button('reset');
								}else{
									if(res.msg!='用户未登录'){
										mui.toast(res.msg);
									}
									setTimeout(function(){
										mui("#savePatient").button('reset');
									}, 5000);
								}
							},
							error: (xhr, type, errorThrown) =>{
								console.log('err'+type);
							}
						});
					},
					checkMultiBarcode(dataArr){
						let _this = this;
						// {
						// 	outLabId:outLabId,
						// 	partnerHospitalLabId: _this.partnerHospitalLabId,
						// 	specimenBarcode: barCode
						// }
						let url = '/partner-sale/ludan/checkSpecimenBarcodeListIsUnique';
						mui.ajax(AT.baseUrl + url, {
							data:{
								specimenBarCodeParamList:dataArr
							},
							dataType: 'json', //服务器返回json格式数据
							type: 'post', //HTTP请求类型
							//timeout: 10000, //超时时间设置为10秒；
							crossDomain: true,
							headers:{'Content-Type':'application/json'},
							success: (res)=>{
								if(res.code === 0){
									// _this.applyShow = true;
									// _this.samplingShow = false;
									_this.confirmSamp();
									console.log('该条码可用!');
									console.log(_this.isBarcodeSure);
								}else if(res.code === 1){
									_this.$forceUpdate();
									mui.toast(res.msg);
									_this.applyShow = false;
									_this.samplingShow = true;
									console.log(_this.isBarcodeSure);
								}else{
									_this.applyShow = false;
									_this.samplingShow = true;
									if(res.msg!='用户未登录'){
										mui.toast('系统错误，请稍后再试！');
									}
									console.log(_this.isBarcodeSure);
								}
							},
							error: (xhr, type, errorThrown) =>{
								console.log('err'+type);
							}
						});
					},
					//采样时间选择器
					selectSamplingTime(){
						let _this = this;
						var options = {"type":"datetime","beginYear":1900,"endYear":2100};
						picker = new mui.DtPicker(options);
						picker.show(function(rs) {
							_this.samplingTime=rs.value;
							picker.dispose();
							picker = null;
						});
					},
					/*试管加减*/
					plusNum(index,scIndex){
						console.log(index,scIndex);
						console.log(this.SamplingParams[index].samplingColorVos[scIndex].samplingNum)
						this.SamplingParams[index].samplingColorVos[scIndex].samplingNum++;
					},
					minusNum(index,scIndex){
						console.log(index,scIndex);
						if(this.SamplingParams[index].samplingColorVos[scIndex].samplingNum>1){
							this.SamplingParams[index].samplingColorVos[scIndex].samplingNum--;
						}
					},
					getNoticeList(id){
						let _this = this;
						AT.muiAjax('/partner-sale/ludan/orderNotifyConfig','post',{
							id:id
						},function(res){
							switch(id){
								case 2:
									_this.saleNoticeList = res;
									break;
								case 3:
									_this.doctorNoticeList = res;
									break;
								case 4:
									_this.patientNoticeList = res;
									break;
							}
							console.log(res);
						});
					},
					uploadImg(){
						console.log('点击上传')
						let _this = this;
						// _this.uploadIndex = 0;
						let len = 0;
						if (_this.imgSrcs!=null){
							len = _this.imgSrcs.length;
						}
						var y = 0;
								var i = 0;
						if(len<5){
							var localIds = [];
							wx.chooseImage({
								count: 5-len, // 默认9
								sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
								sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
								success: function (res) {
									console.log(res)
									localIds = res.localIds;
									// 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
									syncUpload(localIds);
								}
							});
							function syncUpload(localIds){
								var localId = localIds.pop();
								wx.uploadImage({
									localId: localId,
									isShowProgressTips: 1,
									success: function (res) {
										i++;
										var serverId = res.serverId; // 返回图片的服务器端ID
										_this.imgSrcs.push(localId);
										console.log(_this.imgSrcs)
										_this.imgIds.push(serverId);
										console.log(_this.imgIds)
										if(localIds.length>0){
											syncUpload(localIds);
										}
									}
								});
							}; 
						}
					},
					/*调用微信接口展示图片*/
					getImg(src){
						let _this=this;
						wx.previewImage({
							current: src, // 当前显示图片的http链接
							urls:_this.imgSrcs// 需要预览的图片http链接列表
						});
					},
					/*调用微信接口展示图片*/
					getSampImg(src,event){
						console.log(src)
						if(src){
							let _this=this;
							let imgSrcs = [];
							imgSrcs.push(src);
							wx.previewImage({
								current: src, // 当前显示图片的http链接
								urls:imgSrcs// 需要预览的图片http链接列表
							});
						}else{
							event.preventDefault();
						}
					},
					getImgSrc(mediaId){
						// 153957
						let src = "https://api.lis.ulabcare.com/api/common/common/downLoadFile?attachId="+mediaId+"&type=0";
						return src;
					},
					selectSale(){
						console.log(this.saleShow)
						if(this.saleShow){
							this.saleShow = false;
							let index = this.notifyUserTypes.findIndex(target=>target==2);
							if(index!=-1){
								this.notifyUserTypes.splice(index,1);
							}
							console.log(this.notifyUserTypes)
						}else{
							this.saleShow = true;
							this.getNoticeList(2);
							this.notifyUserTypes.push(2);
							console.log(this.notifyUserTypes)
						}
					},
					selectDoctor(){
						if(this.doctorShow){
							this.doctorShow = false;
							let index = this.notifyUserTypes.findIndex(target=>target==3);
							if(index!=-1){
								this.notifyUserTypes.splice(index,1);
							}
							console.log(this.notifyUserTypes)
						}else{
							this.doctorShow = true;
							this.getNoticeList(3);
							this.notifyUserTypes.push(3);
							console.log(this.notifyUserTypes)
						}
					},
					selectPatient(){
						if(this.patient1Show){
							this.patient1Show = false;
							let index = this.notifyUserTypes.findIndex(target=>target==4);
							if(index!=-1){
								this.notifyUserTypes.splice(index,1);
							}
							console.log(this.notifyUserTypes)
						}else{
							this.patient1Show = true;
							this.getNoticeList(4);
							this.notifyUserTypes.push(4);
							console.log(this.notifyUserTypes)
						}
					},
					//提交
					submitInfo(){
						let _this = this;
						console.log(_this.imgIds);
						console.log(_this.specimenSamplingParams);
						// return;
						AT.muiAjax('/partner-sale/ludan/perfectPatientTemporaryOrder','post',{
							// "notifyUserTypes":_this.notifyUserTypes,
							"orderId":_this.orderId,
							"samplingTime":_this.samplingTime,
							"specimenSamplingParams":_this.specimenSamplingParams,
							"wxAttachmentIds":_this.imgIds
						},function(res){
							console.log(res);
							mui.confirm('请根据您的需求选择','提示',['继续关联','待确认订单','返回首页'],function(e){
								console.log(e.index)
								if (e.index == 0) {
									location.href = 'noCodeList.html';
								} else if (e.index == 1) {
									location.href = '../order/order.html';
								}else {
									location.href = '../index.html';
								}
							},'div');
						});
					}
				}
			})
		</script>
	</body>
</html>
